cordova.define("bsl.cordova.plugins.dowm.downloadManager", function(require, exports, module) {
               
               
               
               var exec = require('cordova/exec');
               var cordova = require('cordova');
               var utils = require('cordova/utils');
               var downitem = require('./downitem');
               
               
               var downloadManager = {
               description: "管理下载任务",
               
                allTask:[],
               
               createDownload : function (option, completedCB) {
               
               var a=true;
               var down;
               for (var d=0;d<this.allTask.length;d++){
                 var dowm=this.allTask[d];
               if(a==true&&(dowm.fileName==option.fileName)){
               a=false;
               down=dowm;
               }
               }
               
               if(a){
              down = new downitem("",option.fileName, '','','',option.url,'','','')
               this.allTask.push(down);
               }
               
               
               cordova.exec(function () {
//                            alert('下载AA');
                            completedCB();
                            }, function () {
//                            alert('下载失败');
                            completedCB();
                            },
                            "download", "createDownload",
                            [{fileName:option.fileName,url:option.url}]);
               
               
               return down;
               
               },
               enumerate : function (successCB, error, option) {
               
               
               alert("enumerate")
               var win = function(result) {
               var cs = [];
               for (var i = 0, l = result.length; i < l; i++) {
               cs.push(downloadManager.create(result[i]));
               }
               
               alert(cs[0].fileID+"999");
               
               successCB(cs);
               }
               var para=[];
               if(typeof option =='undefined'){
                para=[];
               }else{
               para=[{state:option.state,
                }]
               }
               cordova.exec(win,function(){
                            },
                            "download","enumerate",
                            para);

               },
               clear :function () {
               cordova.exec(function () {
                            }, function () {
                            },
                            "download", "clear",
                            []);
               
               },
               startAll : function () {
               
               cordova.exec(function () {
                            }, function () {
                            },
                            "download", "startAll",
                            []);
               
               },
               create: function(properties) {
               
               var down = new downitem();
               for (var i in properties) {
               if (typeof down[i] !== 'undefined' && properties.hasOwnProperty(i)) {
               down[i] = properties[i];
               //                 alert(i + ":"+properties[i]);
               //               alert(i + ":"+down[i]);
               }
               }
               var a=false;
               var dowm;
               
               for (dowm in this.allTask){
               if(a==false&&(dowm.fileName==down.fileName)){
               a=true;
               }
               }
               if(!a){
               this.allTask.push(down)
               }
               
               alert (down.fileID+down.fileName);
               return down;
               }
               
               
               
               
               
               
               }
               function install() {
               if (!window.plugins) {
               window.plugins = {};
               }
               
               window.plugins.downloadManager =  downloadManager;
               return window.plugins.downloadManager;
               }
               
               module.exports =  downloadManager;
               
//               cordova.addConstructor(install);
               
               
               });

